<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Open a persistent connection to an Erlang node</title>
 </head>
 <body>
 
<div id="peb-pconnect" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">peb_pconnect</h1>
  <p class="refpurpose"><span class="refname">peb_pconnect</span> &mdash; <span class="dc-title">Open a persistent connection to an Erlang node</span></p>

 </div>

 <a name="peb-pconnect.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">resource</span> <span class="methodname"><b>peb_pconnect</b></span>
    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$server</tt></span>
   , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$cookie</tt></span>
    )</div>

  
  <p class="para rdfs-comment">
   Establishes a persistent connection to an Erlang node.
  </p>
  
  <p class="para">
   <b>peb_pconnect()</b> acts very much like
   <a href="peb-connect.html" class="function">peb_connect()</a> with two major differences.
  </p>
  <p class="para">
   First, when connecting, the function would first try to find a
   (persistent) link that&#039;s already open with the same server,
   cookie and creation.  If one is found, an identifier for it
   will be returned instead of opening a new connection.
  </p>
  <p class="para">
   Second, the connection to the Erlang node will not be closed when
   the execution of the script ends.  Instead, the link will remain
   open for future use.
  </p>
  <p class="para">
   This type of link is therefore called &#039;persistent&#039;.
  </p>
 </div>


 <a name="peb-pconnect.parameters"></a><div class="refsect1 parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   </p><dl>

    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">server</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       The Erlang node.  e.g. &quot;nodename@host.domain&quot; 
      </p>
     </dd>

    
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">cookie</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       The cookie for communicate with this Erlang node.
      </p>
     </dd>

   </dl>
<p>
  </p>
 </div>


 <a name="peb-pconnect.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns an Erlang node persistent link identifier on success, or <b><tt class="constant">FALSE</tt></b> on 
   failure.
  </p>
 </div>



 <a name="peb-connect.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <p><b>Example #1 <b>peb_pconnect()</b> example</b></p>
  <p class="para">
   </p><div class="example">
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$link&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">peb_pconnect</span><span style="color: #007700">(</span><span style="color: #DD0000">'node@host.domain'</span><span style="color: #007700">,&nbsp;</span> <span style="color: #DD0000">'secret_cookie'</span><span style="color: #007700">);<br />if&nbsp;(!</span><span style="color: #0000BB">$link</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;die(</span><span style="color: #DD0000">'Could&nbsp;not&nbsp;connect:&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">peb_error</span><span style="color: #007700">());<br />}<br />echo&nbsp;</span><span style="color: #DD0000">'Connected&nbsp;successfully'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents para"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Connected successfully
</pre></div>
    </div>
   </div><p>
  </p>
 </div>

 

 <a name="peb-pconnect.notes"></a><div class="refsect1 notes">
  <h3 class="title">Notes</h3>
  <blockquote><p><b class="note">Note</b>: 
   
    Note, that these kind of links only work if you are using
    a module version of PHP. 
   <br />
  </p></blockquote>
 
 </div>


 <a name="peb-pconnect.seealso"></a><div class="refsect1 seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   </p><ul class="simplelist">
    <li class="member"><a href="peb-connect.html" class="function" rel="rdfs-seeAlso">peb_connect()</a> - Open a connection to an Erlang node</li>
	</li>
   </ul><p>
  </p>
 </div>

</div>

</body></html>
